<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Universite extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(3)
     *
     * @var int
     */
    protected $_IdUniv;

    /**
     * Database var type varchar(150)
     *
     * @var string
     */
    protected $_NomUniv;

    /**
     * Database var type varchar(150)
     *
     * @var string
     */
    protected $_AdresseUniv;

    /**
     * Database var type varchar(40)
     *
     * @var string
     */
    protected $_EmailUniv;

    /**
     * Database var type varchar(40)
     *
     * @var string
     */
    protected $_SitewebUniv;



    /**
     * Dependent relation fk_etablissement_universite
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Etablissement
     */
    protected $_Etablissement;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'id_univ'=>'IdUniv',
            'nom_univ'=>'NomUniv',
            'adresse_univ'=>'AdresseUniv',
            'email_univ'=>'EmailUniv',
            'siteweb_univ'=>'SitewebUniv',
        ));

        $this->setParentList(array(
        ));

        $this->setDependentList(array(
            'FkEtablissementUniversite' => array(
                    'property' => 'Etablissement',
                    'table_name' => 'Etablissement',
                ),
        ));
    }

    /**
     * Sets column id_univ
     *
     * @param int $data
     * @return Application_Model_Universite
     */
    public function setIdUniv($data)
    {
        $this->_IdUniv = $data;
        return $this;
    }

    /**
     * Gets column id_univ
     *
     * @return int
     */
    public function getIdUniv()
    {
        return $this->_IdUniv;
    }

    /**
     * Sets column nom_univ
     *
     * @param string $data
     * @return Application_Model_Universite
     */
    public function setNomUniv($data)
    {
        $this->_NomUniv = $data;
        return $this;
    }

    /**
     * Gets column nom_univ
     *
     * @return string
     */
    public function getNomUniv()
    {
        return $this->_NomUniv;
    }

    /**
     * Sets column adresse_univ
     *
     * @param string $data
     * @return Application_Model_Universite
     */
    public function setAdresseUniv($data)
    {
        $this->_AdresseUniv = $data;
        return $this;
    }

    /**
     * Gets column adresse_univ
     *
     * @return string
     */
    public function getAdresseUniv()
    {
        return $this->_AdresseUniv;
    }

    /**
     * Sets column email_univ
     *
     * @param string $data
     * @return Application_Model_Universite
     */
    public function setEmailUniv($data)
    {
        $this->_EmailUniv = $data;
        return $this;
    }

    /**
     * Gets column email_univ
     *
     * @return string
     */
    public function getEmailUniv()
    {
        return $this->_EmailUniv;
    }

    /**
     * Sets column siteweb_univ
     *
     * @param string $data
     * @return Application_Model_Universite
     */
    public function setSitewebUniv($data)
    {
        $this->_SitewebUniv = $data;
        return $this;
    }

    /**
     * Gets column siteweb_univ
     *
     * @return string
     */
    public function getSitewebUniv()
    {
        return $this->_SitewebUniv;
    }

    /**
     * Sets dependent relations fk_etablissement_universite
     *
     * @param array $data An array of Application_Model_Etablissement
     * @return Application_Model_Universite
     */
    public function setEtablissement(array $data)
    {
        $this->_Etablissement = array();

        foreach ($data as $object) {
            $this->addEtablissement($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_etablissement_universite
     *
     * @param Application_Model_Etablissement $data
     * @return Application_Model_Universite
     */
    public function addEtablissement(Application_Model_Etablissement $data)
    {
        $this->_Etablissement[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_etablissement_universite
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Etablissement
     */
    public function getEtablissement($load = true)
    {
        if ($this->_Etablissement === null && $load) {
            $this->getMapper()->loadRelated('FkEtablissementUniversite', $this);
        }

        return $this->_Etablissement;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Universite
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Universite());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Universite::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdUniv() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('id_univ = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdUniv()));
    }
}
